package com.wangyk.mybatis.util;

import java.sql.*;

/**
 * 连接数据库的类
 */
public class DBUtil
{
    public static final String URL = "jdbc:mysql://127.0.0.1:3306/mybatis";
    
    public static final String DRIVER = "com.mysql.jdbc.Driver";
    
    public static final String USER_NAME = "root";
    
    public static final String PASSWORD = "123456";
    
    public static Connection getCon()
        throws ClassNotFoundException, SQLException
    {
        Connection con = null;
        Class.forName(DRIVER);
        con = DriverManager.getConnection(URL, USER_NAME, PASSWORD);
        return con;
    }
    
    public static void Close(Connection con, PreparedStatement pst, ResultSet rs)
        throws SQLException
    {
        if (null != con)
        {
            con.close();
        }
        if (null != con)
        {
            con.close();
        }
        if (null != con)
        {
            con.close();
        }
    }
}
